<%--
  Created by IntelliJ IDEA.
  User: HP
  Date: 2024/12/5
  Time: 13:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div id="content">
    <input  type="text" name="search">

    <ul id="show">

    </ul>
</div>


 <script src="./js/jquery3.6.4.js"></script>
<script>
    let time;
    $(function () {
        $("input[name=search]").keyup(function (event) {
            let val = $(this).val();//获取输入框的内容
            if(val !==""){
                $("#show").show();
                clearTimeout(time);
              time =  setTimeout(function (){
                    LoadEmpsGet(val)
                },500);

            }else {
                $("#show").hide()
            }
        })
    })


/*
    function LoadEmpsGet(name) {
        $.get("/searchName",{name:name},function (data) {
            console.log("响应的数据",data)
        },"json")

    }
*/


    function LoadEmpsGet(name) {
        $.get("/searchName",{name:name},(data)=>{
            console.log("响应的数据",data);
            $(data).each(function (index,item){
                let li = "<li>"+item.name+'=====>'+item.status+"</li>"
                console.log(li)
                $("#show").append(li)
                }
            )
        },"json")



    }


    function LoadEmpsPost(name) {
        $.post("/searchName",{name:name},function (data) {
            console.log("响应的数据",data)
        },"json")

    }

</script>
</body>
</html>
